#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2025/4/15 15:04
# @Author  : Chenmm
# @File    : log.py
# @Software: PyCharm

from app.api import api
from flask import Flask, request, g, jsonify, send_file, session, current_app
from flask_login import login_required, current_user
from app.models import SysRole


# 获取访问统计
@api.route('/logs/visit-trend')
@login_required
def getVisitTrend():
    args = request.args
    pageNum = args.get('startDate', '')  # 页码
    pageSize = args.get('pageSize', '')  # 每页记录数

    data = {
        "dates": [
            "2025-04-15",
            "2025-04-16",
            "2025-04-17",
            "2025-04-18",
            "2025-04-19",
            "2025-04-20",
            "2025-04-21"
        ],
        "pvList": [
            5895,
            6294,
            5834,
            5740,
            2726,
            1599,
            5257
        ],
        "ipList": [
            537,
            519,
            534,
            479,
            227,
            152,
            478
        ]
    }
    return jsonify({'code': '00000', 'data': data, 'msg': '一切ok'})


# 获取访问趋势
@api.route('/logs/visit-stats')
@login_required
def getVisitStats():
    data = {
        "todayUvCount": 478,
        "totalUvCount": 11129,
        "uvGrowthRate": 14.93,
        "todayPvCount": 5257,
        "totalPvCount": 171898,
        "pvGrowthRate": 17.98
    }
    return jsonify({'code': '00000', 'data': data, 'msg': '一切ok'})